package kr.hkit.androidcomplete01.ch06;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class SetParameter extends Activity{

	private Button mLeftbtn;
	private Button mRightbtn;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch06_setparameter);
		
		mLeftbtn = (Button) findViewById(R.id.btnleft);
		mRightbtn = (Button) findViewById(R.id.btnright);
		
		/*mLeftbtn.setOnClickListener(listener);
		mRightbtn.setOnClickListener(listener);*/
	}
	
	/*View.OnClickListener listener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			switch(v.getId()){
			case R.id.btnleft:
				setParam(3,1);
				break;
			case R.id.btnright:
				setParam(1,3);
				break;
			}
			
		}
	};*/
	
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.btnleft:
			setParam(3,1);
			break;
		case R.id.btnright:
			setParam(1,3);
			break;
		}
	}
	
	void setParam(int left, int right){
		LinearLayout.LayoutParams lparam = (LayoutParams) mLeftbtn.getLayoutParams();
		lparam.weight = left;
		mLeftbtn.setLayoutParams(lparam);
		
		LinearLayout.LayoutParams rparam = (LayoutParams) mRightbtn.getLayoutParams();
		rparam.weight = right;
		mRightbtn.setLayoutParams(rparam);
	}
}
